#encoding: utf-8
class WebsController < ApplicationController
  def index
  end

  def help
  end

  def about
  end

  def contact_us
  end

  def products
  end
# 企业主页
  def org_index
    if current_user && current_user.forward?
      @forward = Forward.find(current_user.biz_unit_id)
      @shipowners = @forward.shipowners
      @shippers = @forward.shippers
      @shipper_bls = @forward.shipper_bls(params[:shipper_name])
      @shipowner_bls = @forward.shipowner_bls(params[:shipowner_id])
      respond_to do |format|
        format.html # index.html.erb
        format.json { render :json => {:total_bls => @shipper_bls, :shipowner_bls => @shipowner_bls} }
      end
    end
    if current_user.motorcade?
      @motorcade = MotorCade.find(current_user.biz_unit_id)
      @vehicle_types = @motorcade.vehicles_total
      respond_to do |format|
        format.html # index.html.erb
        format.json { render :json => {:total_vehicles => @vehicle_types} }
      end
    end
    if current_user.shipowner?
      @shipowner = Shipowner.find(current_user.biz_unit_id)
      @forwards = @shipowner.forwards
      @bls_this_year = @shipowner.bls_this_year
      @forward_bls_t = @shipowner.forward_bls_t(params[:forward_id])
      respond_to do |format|
        format.html # index.html.erb
        format.json { render :json => {:forward_bls_t => @forward_bls_t} }
      end
    end
    if current_user.cy?
      @cy = Cy.find(current_user.biz_unit_id)
      @bls_this_year = @cy.bls_this_year
      @all_ctns = @cy.all_ctns
      @cy_ctns = @cy.cy_ctn(params[:status])
      respond_to do |format|
        format.html # index.html.erb
        format.json { render :json => {:cy_bls_t => @bls_this_year, :ctn_status => @cy_ctns} }
      end
    end
  end

  skip_before_filter :require_login
end
